#ifndef PACKET_H
#define PACKET_H

#include "stdint.h"

static const unsigned int HEADER_SIZE = 4;

typedef enum {PACKET_TYPE_CONTROL = 0, PACKET_TYPE_DATA = 1} packet_type;
typedef enum {PACKET_DELIVERY_SYNC = 0, PACKET_DELIVERY_ASYNC = 1} packet_delivery;
typedef enum {PACKET_SCOPE_GLOBAL = 0, PACKET_SCOPE_DEVICE_SPECIFIC = 1} packet_scope;
typedef enum {PACKET_DIRECTION_REQUEST = 0, PACKET_DIRECTION_RESPONSE = 1} packet_direction;

void set_packet_id(unsigned char* packet, uint32_t packet_id);

void set_device_id(unsigned char* packet, uint16_t device_id);

void set_message_info(unsigned char* packet, packet_type type,
        packet_delivery delivery, packet_scope scope, packet_direction direction, 
        uint16_t msg_number);

uint32_t get_packet_id(unsigned char* packet);

uint16_t get_device_id(unsigned char* packet);

packet_type get_packet_type(unsigned char* packet);
packet_delivery get_packet_delivery(unsigned char* packet);
packet_scope get_packet_scope(unsigned char* packet);
packet_direction get_packet_direction(unsigned char* packet);
uint16_t get_message_number(unsigned char* packet);

#endif
